import sys


def solve(nums, target):
    n = len(nums)
    subSum = 0
    res = sys.maxsize
    i = 0
    for j in range(n):
        subSum += nums[j]
        while subSum > target:
            subSum -= nums[i]
            res = min(res, j - i + 1)
            i += 1

    if j - i + 1 == n and subSum < target:
        return 0

    return res


if __name__ == "__main__":
    target = 11
    nums = [1, 1, 1, 1, 1, 1, 1, 1]
    print(solve(nums, target))
